{template 'web/common/common'}
{template 'web/distribution/navbar'}
<link rel="stylesheet" type="text/css" href="../addons/{php echo $_GPC['m']}/resource/swal/dist/sweetalert2.min.css" />
<link rel="stylesheet" type="text/css" href="../addons/kundian_farm/resource/css/layui.css" />
<link rel="stylesheet" type="text/css" href="../addons/kundian_farm/resource/css/new-common.css" />
<blockquote class="layui-elem-quote">
    分销商
</blockquote>

<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
    <ul class="layui-tab-title">
        <a href="{url 'site/entry/distribution',array('m'=>'kundian_farm','op'=>'distribution_user','status'=>2,'version_id'=>$_GPC['version_id'])}" ><li class="{if $status==2}layui-this{/if}">全部</li></a>
        <a href="{url 'site/entry/distribution',array('m'=>'kundian_farm','op'=>'distribution_user','status'=>1,'version_id'=>$_GPC['version_id'])}"><li class="{if $status==1}layui-this{/if}">已审核</li></a>
        <a href="{url 'site/entry/distribution',array('m'=>'kundian_farm','op'=>'distribution_user','status'=>3,'version_id'=>$_GPC['version_id'])}"><li class="{if $status==3}layui-this{/if}">未审核</li></a>
    </ul>
</div>
<div class="layui-form">
    <table class="layui-table">
        <colgroup>
            <col width="150">
            <col width="150">
            <col width="200">
            <col>
        </colgroup>
        <thead>
        <tr>
            <th>UID</th>
            <th>头像</th>
            <th>昵称</th>
            <th>姓名</th>
            <th>手机号</th>
            <th>累计佣金</th>
            <th>可提现佣金</th>
            <th>推荐人</th>
            <th>状态</th>
            <th>申请时间</th>
            <th>审核时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
            {loop $user $key $item}
            <tr>
                <td>{$item['uid']}</td>
                <td><img src="{$item['avatarurl']}" style="width: 50px;height: 50px;" alt=""></td>
                <td>{$item['nickname']}</td>
                <td>{$item['checkInfo']['username']}</td>
                <td>{$item['checkInfo']['phone']}</td>
                <td>{$item['total_price']}</td>
                <td>{$item['price']}</td>
                <td>{$item['one_sale']}</td>
                <td>
                    {if $item['checkInfo']['status']==1}
                    <span class="layui-badge layui-bg-green">通过</span>
                    {else}
                    <span class="layui-badge layui-bg-gray">未审核</span>
                    {/if}
                </td>
                <td>{$item['apply_time']}</td>
                <td>{$item['become_time']}</td>
                <td>
                    {if $item['checkInfo']['status']==0}
                    <button class="layui-btn layui-btn-xs agree" data-id="{$item['checkInfo']['id']}">通过审核</button>
                    <button class="layui-btn layui-btn-sm layui-btn-danger deny" data-id="{$item['checkInfo']['id']}">不通过</button>
                    {/if}

                    <a href="{url 'site/entry/distribution',array('m'=>'kundian_farm','id'=>$item['id'],'op'=>'distribution_withdraw','uid'=>$item['uid'],'version_id'=>$_GPC['version_id'])}">
                        <button class="layui-btn layui-btn-xs">提现详情</button>
                    </a>

                </td>
            </tr>
            {/loop}
        </tbody>
    </table>
</div>
<script>
    require(["../addons/{php echo $_GPC['m']}/resource/swal/dist/sweetalert2.min.js"],function(){
        $(function(){
            $(".agree").click(function(){
                var that=$(this);
                var id=$(this).attr('data-id');
                swal({
                    title: '提示',
                    text: '确认通过分销商审核吗？',
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '确认',
                    cancelButtonText: '取消',
                }).then(function(isConfirm) {
                    if (isConfirm) {
                        $.ajax({
                            type:"post",
                            url:"{url 'site/entry/'.$_GPC['do'],array('m'=>$_GPC['m'],'op'=>'agreeSale','version_id'=>$_GPC['version_id'])}",
                            data:{id:id},
                            dataType:'json',
                            success:function(res){
                                if(res.status==1){
                                    swal('提示', '操作成功!', 'success');
                                    window.location.reload();
                                }else{
                                    swal('提示', res.msg, 'error');
                                }
                            }
                        })
                    }
                })
            });

            $(".deny").click(function(){
                var that=$(this);
                var id=$(this).attr('data-id');
                swal({
                    title: '提示',
                    text: '确认拒绝分销商审核吗？',
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '确认',
                    cancelButtonText: '取消',
                }).then(function(isConfirm) {
                    if (isConfirm) {
                        $.ajax({
                            type:"post",
                            url:"{url 'site/entry/'.$_GPC['do'],array('m'=>$_GPC['m'],'op'=>'denySale','version_id'=>$_GPC['version_id'])}",
                            data:{id:id},
                            dataType:'json',
                            success:function(res){
                                if(res.status==1){
                                    swal('提示', '操作成功!', 'success');
                                    window.location.reload();
                                }else{
                                    swal('提示', res.msg, 'error');
                                }
                            }
                        })
                    }
                })
            });
        })

    })
</script>

